<template>
  <div v-if="Object.keys(detailInfo).length !== 0" class="goods-info">
    <div class="info-desc clear-fix">
      <div class="start"></div>
      <div class="desc">{{detailInfo.desc}}</div>
      <div class="end"></div>
    </div>
    <div class="info-key">{{detailInfo.detailImage[0].key}}</div>
    <div class="info-list">
      <img v-for="(item, index) in detailInfo.detailImage[0].list"
           :key="index"
           :src="item" @load="imgLoad" alt="">
    </div>
  </div>
</template>

<script>
  export default {
    name: "DetailGoodsInfo",
    props: {
      detailInfo: {
        type: Object,
        default() {
          return {}
        }
      }
    },
    data() {
      return {
        counter: 0,
        imagesLength: 0
      }
    },
    methods: {
      imgLoad() {
        if (++this.counter === this.imagesLength) {
          this.$emit('imageLoad')
        }
      }
    },
    watch: {
      detailInfo() {
        this.imagesLength = this.detailInfo.detailImage[0].list.length
      }
    }
  }
</script>

<style scoped>
  .goods-info {
    pading: 200px 0;
    border-bottom: 5px solid #f2f5f8;
  }

  .start {
    padding: 10px;
    border-bottom: 2px solid #9c9c9c;
    width: 90px;
    margin-left: 10px;
  }

  .desc {
    padding: 20px 0;
    font-size: 13px;
    margin: 0 10px;
  }

  .end {
    position: relative;
    float: right;
    width: 90px;
    padding: 10px;
    border-top: 2px solid #9c9c9c;
    margin-right: 10px;
  }

  .info-key {
    margin-left: 20px;
  }


  .info-list {
    display: inline-block;
    padding-bottom: 50px;
    background-color: #fff;
  }

  .info-list img {
    width: 100%;
    vertical-align: middle;
  }


</style>
